﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace System8ToyMC
{
	public partial class LoadFromTextDialog : UserControl
	{
		public LoadFromTextDialog()
		{
			// Required to initialize variables
			InitializeComponent();
            LayoutRoot.DataContext = this;
		}

        /// <summary>
        /// The string that contains the property text
        /// </summary>
        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(LoadFromTextDialog), new PropertyMetadata(""));
        
        /// <summary>
        /// When the user hits the "cancel" button, this guy is fired.
        /// </summary>
        public event Action<object, EventArgs> CancelConvert;

        /// <summary>
        /// When the user hits "Convert" this guy is called to fire off the convert button!
        /// </summary>
        public event Action<object, EventArgs> Convert;

        /// <summary>
        /// Fire the cancel event.
        /// </summary>
        protected void DoCancelConvert()
        {
            if (CancelConvert != null)
            {
                CancelConvert(this, new EventArgs());
            }
        }

        /// <summary>
        /// Fire the convert event.
        /// </summary>
        protected void DoConvert()
        {
            if (Convert != null)
            {
                Convert(this, new EventArgs());
            }
        }

        private void BCancel_Click(object sender, RoutedEventArgs e)
        {
            DoCancelConvert();
        }

        private void BConvert_Click(object sender, RoutedEventArgs e)
        {
            DoConvert();
        }
	}
}